<template>
  <div>
    <!-- 查询插件 -->
        <!-- 查询插件 -->
   

    <!-- stu展示插件 -->
    <div>
      <el-table :data="pageBean.beanList" border style="width: 100%"  >
        <el-table-column prop="logid" label="操作编号"  align="center"></el-table-column>
        <el-table-column prop="username" label="操作账号"  align="center"></el-table-column>
        <el-table-column prop="hostip" label="操作主机ip"  align="center"></el-table-column>
        <el-table-column prop="content" label="操纵描述"  align="center"></el-table-column>
        <el-table-column prop="operatortime" label="操作时间"  align="center"></el-table-column>

        <el-table-column label="操作"  align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 分页插件 -->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageBean.pageIndex"
        :page-sizes="[3, 4, 5, 6]"
        :page-size="pageBean.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageBean.totalRecord"
      ></el-pagination>
    </div>


  <!-- 添加故障的模态框 -->
     





    <!-- 模态框插件 -->
    
    
  </div>
</template>


<script>
//导入axios
import axios from "axios";

export default {
  data() {
    return {
      // tableData: [],
      pageIndex: 1,
      pageSize: 5,
      pageBean: {
        beanList: [],
        pageIndex: 0,
        pageSize: 0,
        totalRecord: 0,
        totalPage: 0
      },
      role: [],
      dept: [],
      rules: {

        // rentcarprice: [
        //   { required: true, message: "请输年龄", trigger: "blur" },
        //   { min: 1, max: 10, message: "长度在 1 到 10个字符", trigger: "blur" }
        // ]
        
      },
      dialogFormVisible: false,
      dialogFormVisibletwo:false,
      title: ""
    };
  },
  created() {
    //生命周期方法
     this.getOrdersLogList();
  },
  methods: {
  
    handAddWarn(){
       this.dialogFormVisibletwo = true;
        this.AddParams = { ...row };
    },
    handleEdit(index, row) {
      console.log(index, row);
     
      this.dialogFormVisible = true;
      this.eitParams = { ...row };
      this.eitParams.did=row.dept.deptname;
      this.title = "编辑";
    },
    handleDelete(index, row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$axios
            .delete("http://localhost:8601/myorders/dellog/" + row.logid)
            .then(resp => {
              console.log(resp.data);
              if(resp.data.code==500){
                this.$message("你没有操作权限");
              }else{
                 this.$message("删除成功");
              }
              this.getOrdersLogList();
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },

   getOrdersLogList() {
      this.$axios
        .get("http://localhost:8601/myorders/AllOrdersLog", {
          params: {
            pageIndex: this.pageIndex,
            pageSize: this.pageSize,
          }
        })
        .then(resp => {
          console.log(resp.data)
          if(resp.data.code==500){
               this.$router.push('/');
          }else{
            this.pageBean = resp.data.data;
          }
        });
    },
    closeDialog() {
      console.log("模态框关闭");
      this.eitParams = {};
      this.$refs["eitParams"].clearValidate();
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getstaffList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageIndex = val;
      this.getstaffList();
    }
  }
};
</script>

<style>
</style>
